Skip to content

[#619] Remove the hierarchy flag from Config Setup - #704

Merged
armanist merged 1 commit into
quantum-php:3.2.xfrom
armanist:issue/619-remove-config-hierarchy
Nov 23, 2026
Merged

armanist merged 1 commit into
quantum-php:3.2.xfrom
armanist:issue/619-remove-config-hierarchy

Conversation

@armanist

@armanist armanist commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #619

What

Removes the hierarchy flag of Quantum\Config\Setup, deprecated in 3.1.2 (#618): the $hierarchical constructor argument, setHierarchy() and getHierarchy(). A module's config file that does not exist always falls back to shared/config.

  • Setup::__construct() is now ($pathPrefix, $fileName, $module, $exceptionMessage).
  • ConfigFileTrait::resolveFilePath() no longer checks the flag before the shared fallback.

Why

Nothing in the framework turned the fallback off, and turning it off broke the loading of the global config in shared/config, which is found only through the fallback. 3.1.2 deprecated the flag and announced its removal in 3.2.0.

Breaking

The module and the exception message move up one position: new Setup('config', 'app', true, 'Admin') must become new Setup('config', 'app', module: 'Admin'). In a file that declares strict_types, the old call fails with a TypeError; without it, PHP turns true into the module 1 and false into no module, and the module name becomes the exception message, so the config is read from shared or from the wrong module without an error. Calls that pass only the first two arguments, or the module as a named argument, are unaffected. setHierarchy() and getHierarchy() are gone.

Changed paths

  • src/Config/Setup.php
  • src/Config/Traits/ConfigFileTrait.php
  • tests/Unit/Config/SetupTest.php, tests/Unit/Config/ConfigTest.php
  • tests/Unit/Database/DatabaseTest.php, tests/Unit/Database/Factories/TableFactoryTest.php, tests/Unit/Migration/MigrationManagerTest.php, tests/Unit/Validation/Traits/GeneralRuleTest.php
  • CHANGELOG.md

Testing

  • New tests in SetupTest fail without the change: testThirdArgumentIsTheModule (the module was null), testFourthArgumentIsTheExceptionMessage (the module was the message) and testHierarchyMethodsAreRemoved.
  • The tests that passed the flag positionally now pass the module as a named argument, or nothing. They passed on the old code with that change, and pass after it; testImportFallsBackToSharedConfig covers the fallback for a module without its own file.
  • The tests of the removed API are deleted: testSetGetHierarchy, the three deprecation tests that passed the flag, and testImportDoesNotFallBackWhenHierarchyIsDisabled.

Summary by CodeRabbit

  • Breaking Changes
    • Removed the configuration hierarchy option and its related methods. Update constructor calls to the new argument order; use the named module argument when specifying a module.
  • Bug Fixes
    • Configuration lookup now checks the shared configuration path when a module-specific file is missing, regardless of hierarchy settings.
  • Documentation
    • Added migration guidance covering the updated constructor arguments and the behavior of legacy positional calls.

@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Setup removes its hierarchy flag and methods. When the initial configuration path is missing, lookup now checks the shared configuration path. Tests and the changelog reflect the constructor and fallback changes.

Changes: Configuration setup and resolution

Layer / File(s) Summary
Remove the hierarchy API
src/Config/Setup.php, tests/Unit/Config/SetupTest.php, tests/Unit/Database/*, tests/Unit/Migration/*, tests/Unit/Validation/Traits/*, CHANGELOG.md
Setup removes the hierarchy property, constructor argument, and methods. Tests and database setup callers use the revised constructor arguments. The changelog documents the breaking change.
Use shared configuration fallback
src/Config/Traits/ConfigFileTrait.php, tests/Unit/Config/ConfigTest.php
When the initial configuration path is missing, lookup checks the shared path without a hierarchy check. Configuration tests use the named module argument and remove the test that expected fallback to be disabled.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Refactor · Severity of issue fixed: Medium

Possibly related issues

  • Issue 649 describes a broader configuration resolution flow that includes the shared fallback changed here. Its package-default and config:publish objectives are not addressed by this change.

Suggested reviewers: andrey-smaelov, artem-dev2

Merge Risk: Minimal · up to 9386a

Setup no longer takes a hierarchy flag, and a missing module config file now always falls back to the shared config. Callers that pass the module positionally must switch to the named module argument, and the changelog explains how. No concrete merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "[#619] Remove the hierarchy flag from Config Setup" matches the main change. The changeset removes the $hierarchical constructor parameter, setHierarchy() and getHierarchy() from Quantum\Co…
Linked Issues check Passed Directly linked issue #619 has coding requirements. The PR meets them.

[Removal of the hierarchy flag] The PR removes the $hierarchical constructor parameter from Setup, plus setHierarchy() and…
Out of Scope Changes check Passed All changed paths relate to #619. src/Config/Setup.php and src/Config/Traits/ConfigFileTrait.php implement the removal and the unconditional fallback. CHANGELOG.md documents the breaking change.…
Full details: Title check

Explanation

The title "[#619] Remove the hierarchy flag from Config Setup" matches the main change. The changeset removes the $hierarchical constructor parameter, setHierarchy() and getHierarchy() from Quantum\Config\Setup, and makes the shared fallback unconditional in ConfigFileTrait. The title names the removed flag and the affected class, and it cites linked issue #619. It does not mention the fallback behavior change or the breaking constructor argument shift, but it does not need to cover every detail.

Full details: Linked Issues check

Explanation

Directly linked issue #619 has coding requirements. The PR meets them.

[Removal of the hierarchy flag] The PR removes the $hierarchical constructor parameter from Setup, plus setHierarchy() and getHierarchy(). The new constructor is ($pathPrefix, $fileName, $module, $exceptionMessage). The summary confirms this at the reviewed head.

[Unconditional shared fallback] ConfigFileTrait::resolveFilePath() no longer checks the flag before the shared fallback. The summary confirms this change.

[Tests] SetupTest adds testThirdArgumentIsTheModule, testFourthArgumentIsTheExceptionMessage, and testHierarchyMethodsAreRemoved. The tests that used the old positional flag now use the named module argument. testImportFallsBackToSharedConfig covers the fallback for a module without its own file. The summary does not show a test that asserts the fallback directly for a module with no file. The existing fallback test is assumed to cover it.

[Changelog] CHANGELOG.md documents the breaking signature change with migration guidance. This meets the changelog part of the documentation criterion.

Non-coding gaps: the changed-path list does not include the upgrade guide or the sentence in advanced-features/configuration.md. The issue asks for both. Documentation edits and the report of composer command results are non-coding tasks. They do not change this coding verdict.

Full details: Out of Scope Changes check

Explanation

All changed paths relate to #619. src/Config/Setup.php and src/Config/Traits/ConfigFileTrait.php implement the removal and the unconditional fallback. CHANGELOG.md documents the breaking change. The test files tests/Unit/Config/SetupTest.php and tests/Unit/Config/ConfigTest.php cover the new behavior. The tests DatabaseTest, TableFactoryTest, MigrationManagerTest, and GeneralRuleTest changed only one call each. Those calls stopped passing the removed positional true. These edits are needed because the constructor signature changed. No unrelated change appears in the summary.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 818a83b and 9386a48.

Files selected for processing: 9

  • CHANGELOG.md
  • src/Config/Setup.php
  • src/Config/Traits/ConfigFileTrait.php
  • tests/Unit/Config/ConfigTest.php
  • tests/Unit/Config/SetupTest.php
  • tests/Unit/Database/DatabaseTest.php
  • tests/Unit/Database/Factories/TableFactoryTest.php
  • tests/Unit/Migration/MigrationManagerTest.php
  • tests/Unit/Validation/Traits/GeneralRuleTest.php

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@codecov

codecov Bot commented Nov 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@armanist
armanist merged commit 1da4655 into quantum-php:3.2.x Nov 23, 2026
6 checks passed
@armanist
armanist deleted the issue/619-remove-config-hierarchy branch November 23, 2026 21:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants